package com.moto.mapper;

import com.moto.entity.User;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.moto.entityDto.UpdateUser;
import com.moto.entityDto.UserLoginDto;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

/**
 * <p>
 * 员工表 Mapper 接口
 * </p>
 *
 * @author afei
 * @since 2023-08-28
 */
@Mapper
public interface UserMapper extends BaseMapper<User> {

    @Select("select * from user where phone = #{phone} and is_delete=1")
    User getByPhone(String phone);

    @Select("select count(*) from user where phone = #{phone}")
    int findPhoneIsNull(String phone);

    @Insert("insert into user (phone,password,username,photo,age,address,nickname,sex,is_delete,ban) " +
            "values (#{phone},#{password},#{username},#{photo},#{age},#{address},#{nickname},#{sex},1,1)")
    void registerUser(User user);

    /**
     * 用户修改个人信息
     * @param updateUser
     */
    void updateUser(UpdateUser updateUser);
}
